package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.StorageTankInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.StorageTankUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.StorageTankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　StorageTankController
 *
 * @author fbl
 * @date 2019-11-12 17:54
 */
@RestController
@Validated
@Api(value = "企业储罐信息")
public class StorageTankController {

    @Resource
    StorageTankService storageTankService;

    @ApiOperation(value = "查询企业储罐信息列表")
    @GetMapping(value = "data/basic/enterprise/tanks")
    public Result getEntprTanks(String entprName, String tankNo,Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return storageTankService.getEntprTanks(entprName,tankNo,entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业储罐信息列表")
    @PutMapping(value = "data/basic/enterprise/tanks")
    public Result updateEntprTanks(@RequestBody @Valid StorageTankUpdateDTO storageTankUpdateDTO) {
        return storageTankService.updateEntprTanks(storageTankUpdateDTO);
    }

    @ApiOperation(value = "新增企业储罐信息列表")
    @PostMapping(value = "data/basic/enterprise/tanks")
    public Result insertEntprTanks(@RequestBody @Valid StorageTankInsertDTO storageTankInsertDTO) {
        return storageTankService.insertEntprTanks(storageTankInsertDTO);
    }

    @ApiOperation(value = "删除企业储罐信息列表")
    @DeleteMapping(value = "data/basic/enterprise/tanks/{id}")
    public Result deleteEntprTanks(@PathVariable @NotNull Long id) {
        return storageTankService.deleteEntprTanks(id);
    }

    @ApiOperation(value = "查询企业储罐信息列表详情")
    @GetMapping(value = "data/basic/enterprise/tanks/{id}")
    public Result getEntprTankById(@PathVariable @NotNull Long id) {
        return storageTankService.getEntprTankById(id);
    }
}